GPTs for keyshot coding

So, I’ve been trying the lazy way to figure out how to code some simple stuff for KS. The last thing I coded was in BASIC on my C64 30 years ago, and even then it was a simple counter function. So, imagine my excitement when I did some reading about ChatGPT able to do coding from prompts! So, I finally got a pro subscription to CatGPT through work for some other stuff, and I spent a couple of hours with it trying to make a script that would read the selected objects in the scene tree and align them using the center of the bounding box. It wrote some stuff, pasted into a text doc, saved as a .py and then spent hours chucking errors back and forth and trying new versions.

Didn’t work.

Then i found GPTs that were labled for Keyshot! So i figured that these were trained and were taught the KS API and python modules, classes and libraries and whatever, but I got the same results.

image

(and don’t get too excited about the HDRI generator, its neat and it works, but only outputs 1792x1080 webp images. Might try to use Gigapixel on them. Neat thing is it DOES ask you if you want a backplate :slight_smile: )

Anyway, I know the right way to go is to take a python course and learn it right, but just wondering if I am missing something? Is there a way to “teach” the GPT the API? I can’t even find proper documentation as to what all the classes and modules are for KS scripting, the docs just say “look at the scripts provided and modify as needed”. Is there a better resource to learn about what you can actually do with scripting? Is what I tried actually not possible with scripting but ChatGPT just doesn’t know it can’t?

Thanks!

Cool! I haven’t tried it with Python yet but was coding some PHP/Javascript since many years again and while it also made plenty of mistakes, if I told ChatGPT it didn’t work it changed some stuff or asked me to put some code in to monitor some values. That worked pretty well.

I just got angry at ChatGPT when it kept sending me the same code with errors. And if I pointed that out to ChatGPT it said sorry and did again send me the same code.

I’m not sure how you start the conversation with ChatGPT but I always ask first if it does know specific functions/classes like the one from KeyShot. And if it comes up with something which doesn’t work, I mention it doesn’t work and ask to fix it. Which most of the time helped but it’s handy if you know to monitor values of certain variables since that makes it way easier to find basic mistakes.

You can also just drop your entire code into ChatGPT and ask it to look for mistakes. That works if your code is less than 2000 characters if I’m correct. Does also wonders when I wanted to tidy up my 90’s coding ‘skills’.

I used Visual Code as editor, that’s quite a nifty editor which also can point out mistakes you made if you ‘extend’ it with certain classes like for example the KeyShot specific functions. Not sure if they are available but it can at least prevent default Python errors.

Maybe it’s also good to do it step by step. With for example PHP I ask it for example for a simple function to check the age of a file. And my next question would be to ask for code which deletes or use that file if it’s older than x-seconds.

By doing step-by-step it became also clearer to me what all pieces of code did. For the scripting, the overview of all functions is here: Exposed Headless Scripting Functionality - Keyshot Manual

If you look really really good at the page you find a black word ‘here’ which directs you to the actual documentation: KeyShot 10.2 Scripting Documentation

I think your example of what you were trying was a nice one, might give it a go if I’ve some time left and see how far I’ll get.

1 Like